﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Master/Views/Shared/_Layout.cshtml";
}
@section Header{
    <link href="~/Areas/Master/Common/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
    <script src="~/Areas/Master/Common/js/ztree/jquery.ztree.core-3.5.min.js"></script>
    <script type="text/javascript">
        var objTree;
        var nodes = @Html.Raw(ViewBag.Tree);
        var setting = {
            data: {
                simpleData: {
                    enable: true,
                    idKey: "id",
                    pIdKey: "pid",
                    rootPId: ""
                }
            },
            view: {
                showIcon: false
            },
            callback: {
                onClick: function (event, treeId, treeNode) {
                    getColumns(treeNode.id);
                }
            }
        };
        function getColumns(id) {
            Utils.ajax({
                url: '@Url.Action("GetColumns","Column")',
                data: { 'ID': id },
                type: 'POST',
                success: function (d) {
                    if (d) {
                        var tbl = $('#colTable tbody');
                        tbl.empty();
                        $.each(d, function (i, n) {
                            var tr = $('<tr>' +
                                '<td class="center"><input type="checkbox" class="cboItem" /></td>' +
                                '<td class="center">' + n.Code + '</td>' +
                                '<td>' + n.Title + '</td>' +
                                '<td class="center">' + (n.Type == 0 ? "模型" : "链接") + '</td>' +
                                '<td>' + (n.Type == 0 ? n.ModelCode : n.NavigateUrl) + '</td>' +
                                '<td><input type="text" class="sort large textinput sort center" value="' + n.Sort + '" id="Sort_' + n.ColumnID + '"/></td>' +
                                '</tr>');
                            tbl.append(tr);
                        });
                    }
                },
                error: function (status) { }
            });
        }
        $(function () {
            objTree = $.fn.zTree.init($("#channelTree"), setting, nodes);
            getColumns(0);
        });
</script>
}
<div class="panel grid_8">
    <div class="panel-header">
        <span class="i-24 i-user">文章管理</span>
    </div>
    <div class="panel-body">
        <div>
            <table style="width:100%;height:100%;margin-bottom:0;">
                <tr>
                    <td style="width: 200px; background-color: #efefef; border-right: 1px #ccc solid;">
                        <ul id="channelTree" class="ztree"></ul>
                    </td>
                    <td style="width: auto;">
                        <table id="colTable" class="datatable-fn table" style="width:100%;">
                            <thead>
                                <tr>
                                    <th style="width: 30px;"><input type="checkbox" onchange="Utils.checkAll(this.checked);" /></th>
                                    <th style="width: 100px;">栏目编码</th>
                                    <th style="width: auto;">栏目名称</th>
                                    <th style="width: 100px;">栏目类型</th>
                                    <th style="width: 300px;">模型/链接</th>
                                    <th style="width: 50px;">排序号</th>
                                </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>